package easy

import "workspace/node"

func MergeTrees(root1 *node.TreeNode, root2 *node.TreeNode) *node.TreeNode {
	if root1 == nil {
		return root2
	}
	if root2 == nil {
		return root1
	}
	merged := &node.TreeNode{Val: root1.Val + root2.Val}
	merged.Left = MergeTrees(root1.Left, root2.Left)
	merged.Right = MergeTrees(root1.Right, root2.Right)
	return merged
}
